package com.style.dynamic;

import com.style.core.*;

import java.lang.reflect.Method;

public class DynamicTest {
    public static void main(String[] args) {
        try {
            MouseEventCallback callback=new MouseEventCallback();
            Method onClick = callback.getClass().getMethod("onClick", Event.class);
            Method onDoubleClick = callback.getClass().getMethod("onDoubleClick", Event.class);

            Mouse mouse=new Mouse();

            MouseDynamicProxy mouseDynamicProxy = new MouseDynamicProxy();
            mouseDynamicProxy.addLisenter(MouseEventType.ON_CLICK,callback,onClick);
            mouseDynamicProxy.addLisenter(MouseEventType.ON_DOUBLE_CLICK,callback,onDoubleClick);

            IMouse mouseProxy =(IMouse) mouseDynamicProxy .getInstance(mouse);
            mouseProxy.click();
            mouseProxy.doubleClick();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
